/*
    8. Write a program in C to print the date and time before 24 months. 

    Expected Output :

    Today is :          Thu Aug  3 17:27:16 2017                                                                                  
    (DST is not in effect)                                                                                                        
                                                                                                                                
    24 months ago the date was : Mon Aug  3 17:27:16 2015                                                                         
    (DST was not in effect)
*/

// struct tm {
//    int tm_sec;         /* 秒，范围从 0 到 59                */
//    int tm_min;         /* 分，范围从 0 到 59                */
//    int tm_hour;        /* 小时，范围从 0 到 23                */
//    int tm_mday;        /* 一月中的第几天，范围从 1 到 31                    */
//    int tm_mon;         /* 月份，范围从 0 到 11                */
//    int tm_year;        /* 自 1900 起的年数                */
//    int tm_wday;        /* 一周中的第几天，范围从 0 到 6                */
//    int tm_yday;        /* 一年中的第几天，范围从 0 到 365                    */
//    int tm_isdst;       /* 夏令时                        */    
// };

#include <stdio.h>
#include <time.h>

int main(void)
{
    time_t rawt;
    struct tm *info;
    time(&rawt);
    info = localtime(&rawt);
    printf("Today is : %s", asctime(info));
    printf("(DST is %s) \n", (info->tm_isdst ? "in effect" : "not in effect"));
    printf("years = %d\n", info->tm_year);
    info->tm_mon -= 24;
    mktime(info);
    
    printf("\n24 months ago the date was : %s", asctime(info));
    printf("(DST is %s) \n", (info->tm_isdst ? "in effect" : "not in effect"));   

    printf("years = %d\n", info->tm_year);
    
    return 0;
}